package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpIncidentEditNotesTabPageUtil extends
		SeleniumPageUtil {
	public final static By IEN_TD_CUSTOMER = By.xpath("//*[@id='tblResults']/tbody/tr[1]/td[1]");
	public final static By IEN_TD_CREATE = By.xpath("//*[@id='tblResults']/tbody/tr[1]/td[2]");
	public final static By IEN_TD_NOTES = By.xpath("//*[@id='tblResults']/tbody/tr[1]/td[3]");

	public static void enterNotesTab(String incidentId){
		// login into homepage
		SpSearchPageUtil.enter();
		// current window handle
		// make sure search button and incident id input text show
		SeleniumUtil.assertTrue(SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_BUTTON_SEARCH)));
		SeleniumUtil.assertTrue(SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_MAIN_INPUT_INCIDENT_ID)));
		// click the incident id link to enter the edit page
		SpIncidentEditPageUtil.enterIncidentID(incidentId);
		//click Assets link to enter incident/Asset edit page
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_LINK_TAB_NOTES));
		waitForPageToLoad();
	}
	public static void waitForPageToLoad(){
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.waitOnElements(new By[]{
				IEN_TD_CUSTOMER,IEN_TD_NOTES
		});
	}
}
